package com.lingxinst.business.login.vm

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.lingxinst.business.login.constant.LoginType
import com.lingxinst.farm.base.vm.BaseViewModel
import com.lynn.common.utils.spf.LocalCacheUtil

/**
 * @description:
 * @author: Lynn
 * @datetime: 2025/6/13 10:54
 **/
class LoginViewModel : BaseViewModel() {
    private var _loginType = MutableLiveData(LoginType.SMS.value)
    val loginType: LiveData<Int> = _loginType

    private var _phone = MutableLiveData("")
    val phone: MutableLiveData<String> get() = _phone

    private var _pwd = MutableLiveData("")
    val pwd: MutableLiveData<String> = _pwd
    private var _pwdShow = MutableLiveData(false)
    val pwdShow: LiveData<Boolean> = _pwdShow

    private var _code = MutableLiveData("")
    val code: MutableLiveData<String> = _code


    private var _resultCode = MutableLiveData<Int>()
    val resultCode: MutableLiveData<Int> = _resultCode

    fun onBack(){
//        _resultCode.value = ResultCode.LOGIN_BACK

    }


    fun onClickPwdLogin() {
        _loginType.value = when (_loginType.value) {
            LoginType.SMS.value -> LoginType.PWD.value
            else -> LoginType.SMS.value
        }
    }

    fun switchPwdEyeVisibility(isChecked: Boolean) {
        _pwdShow.value = isChecked
    }



    fun onClickLogin() {
//       _resultCode.value = ResultCode.LOGIN_SUCCESS
        LocalCacheUtil.token = "1233"
    }

    /**
     * 登录逻辑
     */
    fun login() {

    }

    fun onCheckedChange(isChecked: Boolean) {

    }


    fun onClickPrivacy() {

    }

    fun onClickUserProtocol() {

    }


}